{include file="public/header" /}
<form class="layui-form">
	<input type="hidden" name="id" value="{$find['id']}">
	<div class="layui-form-item">
		<label class="layui-form-label">标题</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="title" placeholder="请输入标题" value="{$find['title']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">学校</label>
		<div class="layui-input-block">
			<select name="school_id">
				<option value=""></option>
				{foreach($school as $school_v)}
					<option value="{$school_v['school_id']}" {$school_v['school_id']==$find['school_id']?'selected':''}>{$school_v['name']}</option>
				{/foreach}
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">地址</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="address" placeholder="请输入上课地址，如：10幢101室" value="{$find['address']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">学费</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="tuition" placeholder="请输入学费" value="{$find['tuition']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">招收人数</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="people_num" placeholder="请输入招收人数" value="{$find['people_num']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">老师姓名</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="teacher_name" placeholder="请输入老师姓名" value="{$find['teacher_name']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">老师电话</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="teacher_phone" placeholder="请输入老师电话" value="{$find['teacher_phone']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">开始上课</label>
		<div class="layui-input-block">
			<input type="date" class="layui-input" name="class_start_date" placeholder="请选择开始上课时间" value="{$find['class_start_date']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">上课周期</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="class_time" placeholder="请输入上课周期，如：周一 19点-21点" value="{$find['class_time']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">课时</label>
		<div class="layui-input-block">
			<input type="number" class="layui-input" name="class_hour" placeholder="请输入课时" value="{$find['class_hour']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">报名截止</label>
		<div class="layui-input-block">
			<input type="date" class="layui-input" name="class_end_date" placeholder="请选择报名截止时间" value="{$find['class_end_date']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">介绍</label>
		<div class="layui-input-inline">
			<button type="button" class="layui-btn" id="up">上传介绍图片</button>
		</div>
		<div class="layui-form-mid layui-word-aux">支持png,jpg,gif</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">图片预览</label>
		<div class="layui-input-block">
			<div class="layui-upload-list" id="demo" style="width:90%;float:left;">
				{if !empty($find['intr'])}
					{foreach ($find['intr_s'] as $img)}
						<div class="upload_pic_li" style="position:relative;width:100px;float:left;margin:0 10px 10px 0">
							<img style="width:100px;height:100px;" src="{$config['admin_domain'].$img}" class="layui-upload-img" onmouseover="show_img(this)" onmouseleave="hide_img()">
							<input type="hidden" name="pic[]" value="{$img}"/>
							<a class="close-img" href="javascript:;" onclick="deleteImage('{$img}',this);return false;"></a>
						</div>
					{/foreach}
				{/if}
			</div>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">状态</label>
		<div class="layui-input-block">
			<input type="radio" name="status" value="1" title="开启" {$find['status']==1?'checked':''}>
			<input type="radio" name="status" value="0" title="禁用" {$find['status']==0?'checked':''}>
		</div>
	</div>
</form>
<div class="layui-form-item" style="margin-top:10px;">
	<div class="layui-input-block">
		<button type="button" class="layui-btn" onclick="save()">保存</button>
	</div>
</div>
<script type="text/javascript">
	layui.use(['layer','form','upload'],function(){
		var form = layui.form;
		layer = layui.layer;
		$ = layui.jquery;

		upload = layui.upload;
		upload.render({
			elem: "#up",
			url: "{$config['admin_route']}index/upload_img",
			multiple: true,
			number: 10,
			done: function(res,title){
				if(res.code > 0){
					return layer.msg("上传失败，"+res.msg);
				}else{
					$("#demo").append('<div class="upload_pic_li" style="position:relative; width:100px; float:left; margin:0 10px 10px 0"><img style="width:100px;height:100px;" src="'+ res.url +'" class="layui-upload-img" onmouseover="show_img(this)" onmouseleave="hide_img()"><input type="hidden" name="pic[]" value="'+res.data+'"/><a class="close-img" href="javascript:;" onclick="deleteImage(\''+res.data+'\',this);return false;"></a></div>');
				}
			}
		});
	});

	function save(){
		$.post("{$config['admin_route']}oyk/class_edit",$('form').serialize(),function(res){
			if(res.code>0){
				layer.msg(res.msg,{'icon':2});
			}else{
				layer.msg(res.msg,{'icon':1});
				setTimeout(function(){parent.window.location.reload();},1000);
			}
		},'json');
	}
</script>
{include file="public/tail" /}